package org.onvivals.module.ums.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;
import org.onvivals.common.base.BaseEntity;
import org.onvivals.module.ums.entity.dto.WechatUserDto;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 用户表
 */
@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString
@TableName(value = "ums_user", autoResultMap = true)
@Schema(name = "PmsMember对象", description = "用户表")
public class UmsUser extends BaseEntity<UmsUser> {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户id
     */
    @TableId(value = "uid", type = IdType.ASSIGN_ID)
    @JsonSerialize(using= ToStringSerializer.class)
    @Schema(description="用户id")
    private Long uid;

    /**
     * 用户账户(跟accout一样)
     */
    @TableField(value = "username")
    @Schema(description="用户账户(跟accout一样)")
    private String username;

    /**
     * 用户密码（跟pwd）
     */
    @TableField(value = "`password`")
    @Schema(description="用户密码（跟pwd）")
    private String password;

    /**
     * 真实姓名
     */
    @TableField(value = "real_name")
    @Schema(description="真实姓名")
    private String realName;

    /**
     * 身份证号码
     */
    @TableField(value = "card_id")
    @Schema(description="身份证号码")
    private String cardId;

    /**
     * 用户备注
     */
    @TableField(value = "mark")
    @Schema(description="用户备注")
    private String mark;

	/**
	 * 个人简介
	 */
	@Schema(description="个人简介")
	@TableField(value = "introduction",updateStrategy = FieldStrategy.IGNORED)
	private String introduction;

    /**
     * 用户昵称
     */
    @TableField(value = "nickname")
    @Schema(description="用户昵称")
    private String nickname;

    /**
     * 用户头像
     */
    @TableField(value = "avatar")
    @Schema(description="用户头像")
    private String avatar;

    /**
     * 手机号码
     */
    @TableField(value = "phone")
    @Schema(description="手机号码")
    private String phone;

	@TableField(value = "gender")
	@Schema(description= "性别")
	private String gender;

	/**
	 * 生日
	 */
	@TableField(value = "birthday")
	@Schema(description="生日")
	private String birthday;

    /**
     * 添加ip
     */
    @TableField(value = "add_ip")
    @Schema(description="添加ip")
    private String addIp;

    /**
     * 最后一次登录ip
     */
    @TableField(value = "last_ip")
    @Schema(description="最后一次登录ip")
    private String lastIp;

    /**
     * 用户剩余积分
     */
    @TableField(value = "role_num")
    @Schema(description="用户角色数量")
    private Integer roleNum;

    /**
     * 连续签到天数
     */
    @TableField(value = "sign_num")
    @Schema(description="连续签到天数")
    private Integer signNum;

    /**
     * 1为正常，0为禁止
     */
    @TableField(value = "`status`")
    @Schema(description="1为正常，0为禁止")
    private Boolean status;

    /**
     * 用户类型
     */
    @TableField(value = "user_type")
    @Schema(description="用户类型")
    private String userType;

    /**
     * 用户登陆类型，h5,wechat,routine
     */
    @TableField(value = "login_type")
    @Schema(description="用户登陆类型，h5,wechat,routine")
    private String loginType;

    /**
     * 微信用户json信息
     */
    @Schema(description= "微信用户json信息")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private WechatUserDto wxProfile;

	@Schema(description= "会员到期时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date vipExpireTime;
}
